int a = 1;

int MoveUpFlag = 0;
int MoveDownFlag = 0;
int MoveRightFlag = 0;
int MoveLeftFlag = 0;

void setup()
{
  //size(200, 200);
 // noStroke();
  size(640, 360, P3D); 
  background(0);

  
  
  
}

void draw()
{
  lights();
  
  noStroke();
  pushMatrix();
  translate(210, height/2 - 100, 50 + 10*a);
//  if (MoveUpFlag == 1) translate(210, height/2 - 80, 50 + 10*a);
//  if (MoveDownFlag == 1) translate(210, height/2 - 80, 50 - 10*a);
  rotateY(0);
  rotateX(0);
  box(200);
  popMatrix();
  
  noStroke();
  pushMatrix();
  translate(440, height/2 - 100, 50 + 10*a);
//  if (MoveUpFlag == 1) translate(440, height/2 - 80, 50 + 10*a);
//  if (MoveDownFlag == 1) translate(440, height/2 - 80, 50 - 10*a);
  rotateY(0);
  rotateX(0);
  box(200);
  popMatrix();
  

  noStroke();
  pushMatrix();
  translate(100, height/2, 10 + 10*a);
  //rotateY(1.25*a);
  rotateX(0);
  box(250);
  popMatrix();
  
  noStroke();
  pushMatrix();
  /*
  if ((10 + 10*a) == height){
    translate(440, height/2-80, 50 + 10*a);
  }*/
  translate(540, height/2, 10 + 10*a);
  //rotateY(-1.25);
  rotateX(0);
  box(250);
  popMatrix();
  
  if (MoveUpFlag == 1){
    a = a + 1;
    MoveUpFlag = 0;
    background(0);
  }
  if (MoveDownFlag == 1){
    a = a - 1;
    MoveDownFlag = 0;
    background(0);
  }

  
}




//direction movies
void keyPressed()
{
  if (key == CODED) {
    if(keyCode == UP && MoveDownFlag == 0) {
      MoveUpFlag = 1;
      MoveDownFlag = 0;
      MoveRightFlag = 0;
      MoveLeftFlag = 0;
    } 
    if (keyCode == DOWN && MoveUpFlag == 0) {
      MoveUpFlag = 0;
      MoveDownFlag = 1;
      MoveRightFlag = 0;
      MoveLeftFlag = 0;
    }
    if(keyCode == LEFT && MoveRightFlag == 0) {
      MoveUpFlag = 0;
      MoveDownFlag = 0;
      MoveRightFlag = 0;
      MoveLeftFlag = 1;
    } 
    if (keyCode == RIGHT && MoveLeftFlag == 0) {
      MoveUpFlag = 0;
      MoveDownFlag = 0;
      MoveRightFlag = 1;
      MoveLeftFlag = 0;
    }
    if (keyCode == SHIFT){
      javax.swing.JOptionPane.showMessageDialog(null, "Пауза");      
    }
  }

}
